package fhp.hlhj.giantfold.module

import com.lzy.okgo.model.HttpParams
import fhp.hlhj.giantfold.javaBean.AdvBean
import fhp.hlhj.giantfold.network.UrlApis
import fhp.hlhj.giantfold.utils.LogUtil

/**
 * author: FHP
 * data: on 2018\1\22 0022 17:07
 * E-Mail: 103945089@qq.com
 */
class AdvModule {
    interface AdvListener {
        fun showLoading()
        fun onAdvListener(advBean: AdvBean)
    }

    fun getADV(params: HttpParams,listener: AdvListener){
        UrlApis.getAdvs(params)
                .doOnSubscribe {
                    listener.showLoading()
                }
                .subscribe({
                    data->
                    listener.onAdvListener(data)
                },{
                    error->
                    LogUtil.log("获取广告错误${error.toString()}")
                })
    }
}